﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ex1.School
{
    class Course
    {
        private Dictionary<int, Student> courseTable { get; set; }
        
        public void AddStudent(Student student)
        {
            if (!this.courseTable.ContainsKey(student.FacultyNumber))
            {
                if (courseTable.Count < 30)
                {
                    courseTable.Add(student.FacultyNumber, student);
                }
                else
                {
                    throw new InvalidOperationException("Limit of course is reached!");
                }
            }
            else
            {
                throw new ArgumentException("Student already exists!");
            }
        }

        public void RemoveStudent(Student student)
        {
            if (student == null)
            {
                throw new NullReferenceException("Student is null!");
            }
            if (!this.courseTable.ContainsKey(student.FacultyNumber))
            {
                throw new InvalidOperationException("Student is not in the class!");
            }
            else
            {
                this.courseTable.Remove(student.FacultyNumber);
            }
        }

        public Course()
        {
            this.courseTable = new Dictionary<int, Student>();
        }
    }
}
